<template>
	<view>
		<view style="padding:21rpx 28rpx 0rpx 28rpx">
			<view class="top_tip">
				<view style="margin-left:20rpx">
					<eui-uicons size='28' fontFamily="enjoyIcon5" customPrefix="icon-jinggao1" color="#FF7E00" />
				</view>
				<view class="top_tip_title">您可以在一下任务类型中任选一种来创建新的工单</view>
			</view>
		</view>

		<view class="menu-module ellipsis-line-2">任务类型</view>
		<view class="uni-margin-wrap">
			<swiper class="swiper" circular :indicator-dots="true" :autoplay="false">
				<swiper-item v-for="(data, index1) in newMenuList" :key="index1">
					<view class="menu">
						<view class="menu-row-top flex-row">
							<view v-for="(item, index2) in data" :key="index2" class="menu-item"
								@click="onTapMenu(item)">
								<view class="flex-row menu-row-2">
									<view class="img-box">
										<eui-uicons size='64' fontFamily="enjoyIcon5" :customPrefix="item.c_menu_icon"
											:color="themeColor" />
									</view>
									<view class="right-box">
										<view class="title ellipsis-line-2">{{ item.c_menu_title }}</view>
										<view class="description text-ellipsis">{{ item.c_menu_comenu_content }}</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<view class="menu-module ellipsis-line-2">更多功能</view>

		<view class="top-row">
			<eui-row class="demo-eui-row">
				<eui-col v-for="(item, index) in moreMenuList" :key="index" :span="6" :lineHeight="80">
					<view class="grid-item-box" style="background-color: #fff;" @click="openMoreMenu(item)">
						<eui-uicons size='64' fontFamily="enjoyIcon5" :customPrefix="item.c_menu_icon"
							:color="themeColor" />
						<text class="grid-item-box__text">{{item.c_menu_title}}</text>
					</view>

				</eui-col>
			</eui-row>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref, computed } from 'vue';
	import { storeToRefs } from 'pinia';
	import { useThemeStore } from '@/store/themeStore';
	const themeStore = useThemeStore(); // 主题
	const { theme } = storeToRefs(themeStore);
	const themeColor = ref(theme._object.theme == 'theme-blue' ? '#02B7E6' : '#FF6430')

	const props = defineProps<{
		menuList ?: Array<any>;
	}>();
	const emit = defineEmits(['menuItemClick', 'moreMenuClick']);
	const newMenuList = computed(() => {
		let newList = [];
		for (var i = 0; i < props.menuList.length; i += 4) {

			newList.push(props.menuList.slice(i, i + 4));
		}
		return newList;
	});

	const moreMenuList = ref([
		{
			c_menu_title: '扫一扫',
			c_menu_icon: 'icon-saoyisao1'
		},
		{
			c_menu_title: '水印相册',
			c_menu_icon: 'icon-shuiyinxiangce'
		},
		{
			c_menu_title: '加入群组',
			c_menu_icon: 'icon-jiaruqunzu'
		},
    {
      c_menu_title: '任务设置',
      c_menu_icon: 'icon-shezhi'
    },
	])
	const onTapMenu = (item) => {
		emit('menuItemClick', item)
	}
	const openMoreMenu = (item) => {
		emit('moreMenuClick', item)
	}
</script>

<style lang="scss" scoped>
	@import '../../../../main.scss';
	@import '../../../../static/font/enjoyicon5.0/iconfont.css';

	.top_tip {
		background: rgba(255, 126, 0, 0.05);
		border-radius: 10rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;

		.top_tip_title {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 20rpx;
			margin-left: 8rpx;
			color: #666666;
			line-height: 42rpx;
			text-align: left;
			font-style: normal;
		}
	}

	.uni-margin-wrap {
		width: 400rpx;
		width: 100%;
	}

	.swiper {
		height: 300rpx;
	}

	.swiper-item {
		display: block;
		height: 300rpx;
		line-height: 300rpx;
		text-align: center;
	}

	.swiper-list {
		margin-top: 40rpx;
		margin-bottom: 0;
	}

	.uni-common-mt {
		margin-top: 60rpx;
		position: relative;
	}

	.info {
		position: absolute;
		right: 20rpx;
	}

	.uni-padding-wrap {
		width: 550rpx;
		padding: 0 100rpx;
	}

	.menu-module {
		margin: 21rpx 28rpx 20rpx 28rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 600;
		font-size: 28rpx;
		color: #000000;
		line-height: 40rpx;
		text-align: left;
		font-style: normal;
	}

	.menu-row-top {
		padding: 0 28rpx 16rpx;
		width: 100%;
		flex-wrap: wrap;
		box-sizing: border-box;
		// gap: 12px;
		display: flex;
		justify-content: space-between;

		.menu-item {
			flex: 0 0 48.5%;
			margin-bottom: 20rpx;
			background: #F9F9F8;
			border-radius: 20rpx;
		}

		.menu-row-2 {
			padding: 0 20rpx;
			height: 120rpx;
			align-items: center;
			border-radius: 20rpx;
			box-sizing: border-box;

			.img-box {
				margin-right: 16rpx;
				width: 64rpx;
				height: 64rpx;
			}



			.right-box {
				width: 0;
				flex: 1;
			}

			.title {
				font-size: 24rpx;
				color: $enjoy-color-title;
				font-weight: 500;
				font-family: PingFangSC, PingFang SC;
				white-space: nowrap; /* 确保文本在一行内显示 */
			   overflow: hidden; /* 超出容器的文本将被隐藏 */
			   text-overflow: ellipsis; /* 使用省略号表示被截断的文本 */
			}

			.description {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 20rpx;
				color: #888888;
				white-space: nowrap; /* 确保文本在一行内显示 */
				overflow: hidden; /* 超出容器的文本将被隐藏 */
				text-overflow: ellipsis; /* 使用省略号表示被截断的文本 */
			}
		}
	}

	.menu-row-bottom {
		margin: 0 16rpx 24rpx;
		width: calc(100% - 32rpx);

		.img-box {
			margin-bottom: 8rpx;
			width: 88rpx;
			height: 88rpx;
			border-radius: 32rpx;

			.image {
				width: 64rpx;
				height: 64rpx;
			}
		}

		.title {
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			font-size: 24rpx;
			color: #000000;
			text-align: center;
		}
	}

	.top-row {
		background-color: #FFFFFF;
		margin: 12rpx 20rpx 0rpx 20rpx;
		padding: 21rpx 0rpx 50rpx 0rpx;
	}

	.grid-item-box {
		flex: 1;
		// position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;


		&__text {
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			font-size: 26rpx;
			color: #000000;
			line-height: 37rpx;
			text-align: center;
			font-style: normal;
			margin-top: 16rpx;
		}
	}



	::v-deep .swiper .uni-swiper-dot {
		width: 16px !important;
		height: 6rpx;
		border-radius: 5rpx;
		background: #EEEEEE;
	}

	::v-deep .swiper .uni-swiper-dot-active {
		width: 16px !important;
		height: 6rpx;
		border-radius: 5rpx;
		background: var(--theme-color);
	}

	::v-deep .swiper .uni-swiper-dots-horizontal .uni-swiper-dot {
		margin-right: 10rpx;
		bottom: 0rpx !important;
	}

	::v-deep .uni-swiper-dots-horizontal {
		bottom: 0rpx !important;
	}
</style>
